﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NumberTest.Question;

namespace NumberTest.Answer
{
    class Sofia:iNumberTest
    {
        public int CountTest(long start, long end)
        {
            long[] count = new long[10];

            for (long i = start; i <= end; i++)
            {
                long temp = i;
                if (temp == 0) count[0]++;
                while (temp != 0)
                {
                    if (temp % 10 == 0) count[0]++;
                    else if (temp % 10 == 1) count[1]++;
                    else if (temp % 10 == 2) count[2]++;
                    else if (temp % 10 == 3) count[3]++;
                    else if (temp % 10 == 4) count[4]++;
                    else if (temp % 10 == 5) count[5]++;
                    else if (temp % 10 == 6) count[6]++;
                    else if (temp % 10 == 7) count[7]++;
                    else if (temp % 10 == 8) count[8]++;
                    else if (temp % 10 == 9) count[9]++;
                    temp = (long)temp / 10;
                }
            }

            int tag = 0;
            for (; tag < 10; tag++)
            {
                if (count[tag] == count.Max()) break;
            }

            return tag;

        }
    }
}
